package cn.tvplaza.shakeclub.shakermb.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import cn.tvplaza.shakeclub.R;

/**
 * @Created by taylor on 7/11/17.
 * @class 用户抽奖列表适配器
 */

public class UserMoneyAdapter extends RecyclerView.Adapter<UserMoneyAdapter.ViewHolder> {

    private LayoutInflater mInflater;
    private Context context;
    private List<UserMoneyBean> mList;

    public UserMoneyAdapter(Context c, List<UserMoneyBean> list) {
        this.context = c;
        this.mList = list;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        if (position % 3 == 0) {
            holder.msg.setVisibility(View.VISIBLE);
            holder.msg.setText("提现" + mList.get(position).getMsg() + "元");
        } else {
            holder.msg.setVisibility(View.INVISIBLE);
        }
        holder.usrName.setText(mList.get(position).getUserName());
        holder.hint.setText(mList.get(position).getUserHint());

    }


    @Override
    public int getItemCount() {
        return mList.size();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        ViewHolder holder = new ViewHolder(mInflater.inflate(
                R.layout.shake_main_list_item, parent, false));
        return holder;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private TextView usrName;
        private ImageView usrImg;
        private TextView hint;
        private TextView time;
        private TextView msg;

        private ViewHolder(View itemView) {
            super(itemView);
            usrName = (TextView) itemView.findViewById(R.id.tv_usr_name);
            usrImg = (ImageView) itemView.findViewById(R.id.iv_list_item_user_img);
            hint = (TextView) itemView.findViewById(R.id.tv_list_item_hint);
            time = (TextView) itemView.findViewById(R.id.tv_list_item_time);
            msg = (TextView) itemView.findViewById(R.id.tv_usr_msg);

        }

    }

}
